var GA4_RS=function(e){"use strict";function t(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n{var t;const r=null===(t=window.RudderStackGlobals)||void 0===t?void 0:t.errorReporting;r&&e instanceof Error&&r.notify(e)},u=e=>{const t=[];return function(e,r){if("object"!=typeof r||null===r)return r;for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(r)?(i.debug(`Circular Reference detected for key: ${e}`),"[Circular Reference]"):(t.push(r),r)}},l=(e,t)=>{try{return JSON.stringify(e,u())}catch(e){return i.warn("Failed to convert the value to a JSON string."),null}},p=e=>e?0===Object.keys(e).length:(i.warn("input is undefined or null"),!0),d=(e,t,r)=>{let n;try{n=((e,t,r)=>{let n;try{n="string"==typeof e?e:e instanceof Error||e.message?e.message:l(e)}catch(e){n=""}if("object"==typeof(o=e)&&null!==o&&"target"in o){if(e.target&&"script"!==e.target.localName)return"";if(e.target.dataset&&(e.target.dataset.loader!==s||"true"!==e.target.dataset.isnonnativesdk))return"";if(n=`error in script loading:: src:: ${e.target.src} id:: ${e.target.id}`,"ad-block"===e.target.id)return r.page("RudderJS-Initiated","ad-block page request",{path:"/ad-blocked",title:n},r.sendAdblockPageOptions),""}var o;return`[handleError]:: "${n}"`})(e,0,r)}catch(t){i.error("[handleError] Exception:: ",t),i.error("[handleError] Original error:: ",l(e)),c(t)}n&&(i.error(n),(e=>!e.message||!a.some((t=>e.message.includes(t))))(e)&&c(e))},f="Google Analytics 4 (GA4)";function y(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m,g,h,v,_,b,C,w={exports:{}};function O(){if(g)return m;g=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n,i=365.25*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return m=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=n)return s(o,i,n,"day");if(i>=r)return s(o,i,r,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=n)return Math.round(o/n)+"d";if(i>=r)return Math.round(o/r)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},m}function A(){return _||(_=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(v||(v=1,h=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t=0;--o)n.push(t.slice(o).join("."));return n},n.cookie=r,t=e.exports=n}(T,T.exports)),T.exports);const q=y($);function M(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function B(e){return function t(r){return 0===arguments.length||M(r)?t:e.apply(this,arguments)}}function V(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return M(r)?t:B((function(t){return e(r,t)}));default:return M(r)&&M(n)?t:M(r)?B((function(t){return e(t,n)})):M(n)?B((function(t){return e(r,t)})):e(r,n)}}}const G=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function Y(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function H(e,t,r){for(var n=0,o=r.length;n=0;)W(t=X[r],e)&&!te(n,t)&&(n[n.length]=t),r-=1;return n})):B((function(e){return Object(e)!==e?[]:Object.keys(e)})),ne=B((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function oe(e,t,r,n){var o=Y(e);function i(e,t){return ie(e,t,r.slice(),n.slice())}return!H((function(e,t){return!H(i,t,e)}),Y(t),o)}function ie(e,t,r,n){if(J(e,t))return!0;var o,i,s=ne(e);if(s!==ne(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(o=e.constructor,null==(i=String(o).match(/^function (\w*)/))?"":i[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!J(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!J(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var a=r.length-1;a>=0;){if(r[a]===e)return n[a]===t;a-=1}switch(s){case"Map":return e.size===t.size&&oe(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&oe(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=re(e);if(c.length!==re(t).length)return!1;var u=r.concat([e]),l=n.concat([t]);for(a=c.length-1;a>=0;){var p=c[a];if(!W(p,t)||!ie(t[p],e[p],u,l))return!1;a-=1}return!0}var se=V((function(e,t){return ie(e,t,[],[])}));function ae(e,t,r){if(r||(r=new ce),function(e){var t=typeof e;return null==e||"object"!=t&&"function"!=t}(e))return e;var n,o=function(t){var n=r.get(e);if(n)return n;for(var o in r.set(e,t),e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=ae(e[o],!0,r));return t};switch(ne(e)){case"Object":return o(Object.create(Object.getPrototypeOf(e)));case"Array":return o(Array(e.length));case"Date":return new Date(e.valueOf());case"RegExp":return n=e,new RegExp(n.source,n.flags?n.flags:(n.global?"g":"")+(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.sticky?"y":"")+(n.unicode?"u":"")+(n.dotAll?"s":""));case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return e.slice();default:return e}}var ce=function(){function e(){this.map={},this.length=0}return e.prototype.set=function(e,t){var r=this.hash(e),n=this.map[r];n||(this.map[r]=n=[]),n.push([e,t]),this.length+=1},e.prototype.hash=function(e){var t=[];for(var r in e)t.push(Object.prototype.toString.call(e[r]));return t.join()},e.prototype.get=function(e){if(this.length<=180)for(var t in this.map)for(var r=this.map[t],n=0;ne.value===t)).method(...this.getLogData(e))}}getLogData(e){if(Array.isArray(e)&&e.length>0){let t="%c RS SDK";this.scope&&(t=`${t} - ${this.scope}`);t=`${t} %c ${e[0].trim()}`;const r=[];return r.push(t),r.push("font-weight: bold; background: black; color: white;"),r.push("font-weight: normal;"),r.push(...e.slice(1)),r}return e}}const me=["item_id","itemId","product_id","item_name","itemName","name","coupon","item_brand","itemBrand","brand","item_variant","itemVariant","variant","price","quantity","index","position","affiliation","discount","item_category","itemCategory","category","item_category2","item_category3","item_category4","item_category5","item_list_id","item_list_name","location_id"],ge=[{sourceKeys:["product_id","itemId"],destKey:"item_id"},{sourceKeys:["name","itemName"],destKey:"item_name"},{sourceKeys:"coupon",destKey:"coupon"},{sourceKeys:["brand","itemBrand"],destKey:"item_brand"},{sourceKeys:["variant","itemVariant"],destKey:"item_variant"},{sourceKeys:"price",destKey:"price",metadata:{type:"toNumber"}},{sourceKeys:"quantity",destKey:"quantity",metadata:{type:"toNumber"}},{sourceKeys:"position",destKey:"index",metadata:{type:"toNumber"}},{sourceKeys:"affiliation",destKey:"affiliation"},{sourceKeys:"discount",destKey:"discount"},{sourceKeys:["category","itemCategory"],destKey:"item_category"},{sourceKeys:"item_category2",destKey:"item_category2"},{sourceKeys:"item_category3",destKey:"item_category3"},{sourceKeys:"item_category4",destKey:"item_category4"},{sourceKeys:"item_category5",destKey:"item_category5"},{sourceKeys:"item_list_id",destKey:"item_list_id"},{sourceKeys:"item_list_name",destKey:"item_list_name"},{sourceKeys:"location_id",destKey:"location_id"}],he={method:{sourceKeys:"properties.method",destKey:"method"},product_cart_shared_method:{sourceKeys:"properties.share_via",destKey:"method"},currency:{sourceKeys:"properties.currency",destKey:"currency",metadata:{defaultValue:"USD"}},value:{sourceKeys:["properties.total","properties.value","properties.revenue","properties.price"],destKey:"value",metadata:{type:"toNumber"}},product_add_or_remove_value:{sourceKeys:["properties.total","properties.value","properties.revenue",{operation:"multiplication",args:[{sourceKeys:"properties.price"},{sourceKeys:"properties.quantity",defaultVal:1}]}],destKey:"value",metadata:{type:"toNumber"}},search:{sourceKeys:"properties.query",destKey:"search_term"},list_id:{sourceKeys:"properties.list_id",destKey:"item_list_id"},list_name:{sourceKeys:"properties.category",destKey:"item_list_name"},creative_name:{sourceKeys:["properties.creative_name","properties.creative"],destKey:"creative_name"},creative_slot:{sourceKeys:["properties.creative_slot","properties.position"],destKey:"creative_slot"},promotion_id:{sourceKeys:"properties.promotion_id",destKey:"promotion_id"},promotion_name:{sourceKeys:["properties.promotion_name","properties.name"],destKey:"promotion_name"},coupon:{sourceKeys:"properties.coupon",destKey:"coupon"},payment_method:{sourceKeys:"properties.payment_method",destKey:"payment_type"},shipping_method:{sourceKeys:"properties.shipping_method",destKey:"shipping_tier"},order_id:{sourceKeys:"properties.order_id",destKey:"transaction_id"},shipping:{sourceKeys:"properties.shipping",destKey:"shipping",metadata:{type:"toNumber"}},tax:{sourceKeys:"properties.tax",destKey:"tax",metadata:{type:"toNumber"}},content_type:{sourceKeys:"properties.content_type",destKey:"content_type"},item_id:{sourceKeys:["properties.item_id","properties.product_id","properties.sku"],destKey:"item_id"},cart_shared_item_id:{sourceKeys:["properties.item_id","properties.cart_id"],destKey:"item_id"},url:{sourceKeys:["properties.url","context.page.url"],destKey:"page_location"},referrer:{sourceKeys:["properties.referrer","context.page.referrer"],destKey:"page_referrer"},title:{sourceKeys:["properties.title","context.page.title"],destKey:"page_title"}},ve={LOGIN:{event:"login",mapping:[he.method]},SIGN_UP:{event:"sign_up",mapping:[he.method]},GENERATE_LEAD:{event:"generate_lead",mapping:[he.currency,n(n({},he.value),{},{required:!0})]},PRODUCTS_SEARCHED:{event:"search",mapping:[he.search]},PRODUCT_SEARCHED:{event:"search",mapping:[he.search]},PRODUCT_LIST_VIEWED:{event:"view_item_list",itemList:"YES",mapping:[he.list_id,he.list_name]},PROMOTION_VIEWED:{event:"view_promotion",itemList:"YES",mapping:[he.promotion_id,he.creative_slot,he.creative_name,he.promotion_name]},PROMOTION_CLICKED:{event:"select_promotion",itemList:"NO",mapping:[he.promotion_id,he.creative_slot,he.creative_name,he.promotion_name]},PRODUCT_CLICKED:{event:"select_item",item:"YES",mapping:[he.list_id,he.list_name]},PRODUCTS_CLICKED:{event:"select_item",item:"YES",mapping:[he.list_id,he.list_name]},PRODUCT_VIEWED:{event:"view_item",item:"YES",mapping:[he.currency,n(n({},he.value),{},{required:!0})]},PRODUCT_ADDED:{event:"add_to_cart",itemList:"NO",item:"YES",mapping:[he.currency,n(n({},he.product_add_or_remove_value),{},{required:!0})]},PRODUCT_REMOVED:{event:"remove_from_cart",itemList:"NO",item:"YES",mapping:[he.currency,n(n({},he.product_add_or_remove_value),{},{required:!0})]},CART_VIEWED:{event:"view_cart",itemList:"YES",mapping:[he.currency,n(n({},he.value),{},{required:!0})]},CHECKOUT_STARTED:{event:"begin_checkout",itemList:"YES",mapping:[he.currency,he.coupon,n(n({},he.value),{},{required:!0})]},PAYMENT_INFO_ENTERED:{event:"add_payment_info",itemList:"YES",mapping:[he.currency,he.coupon,he.payment_method,n(n({},he.value),{},{required:!0})]},CHECKOUT_STEP_COMPLETED:{event:"add_shipping_info",itemList:"YES",mapping:[he.currency,he.coupon,he.shipping_method,n(n({},he.value),{},{required:!0})]},ORDER_COMPLETED:{event:"purchase",itemList:"YES",mapping:[he.tax,he.coupon,he.shipping,he.currency,n(n({},he.value),{},{required:!0}),n(n({},he.order_id),{},{required:!0})]},ORDER_REFUNDED:{event:"refund",itemList:"NO",mapping:[he.tax,he.coupon,he.shipping,he.currency,n(n({},he.value),{},{required:!0}),n(n({},he.order_id),{},{required:!0})]},PRODUCT_ADDED_TO_WISHLIST:{event:"add_to_wishlist",itemList:"NO",item:"YES",mapping:[he.currency,n(n({},he.value),{},{required:!0})]},PRODUCT_SHARED:{event:"share",mapping:[he.item_id,he.content_type,he.product_cart_shared_method]},CART_SHARED:{event:"share",mapping:[he.content_type,he.cart_shared_item_id,he.product_cart_shared_method]},PAGE:{event:"page_view",mapping:[he.url,he.title,he.referrer]}},_e=[ve.PRODUCT_CLICKED.event,ve.PRODUCT_VIEWED.event,ve.PRODUCT_ADDED.event,ve.PRODUCT_REMOVED.event,ve.PRODUCT_ADDED_TO_WISHLIST.event];var be,Ce,we,Oe;const Ae=y(function(){if(Oe)return we;Oe=1;const e=Ce?be:(Ce=1,be=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)});function t(e,t,r){return"function"==typeof r.join?r.join(e):e[0]+t+e[1]}function r(e,t,r){return"function"!=typeof r.isValid||r.isValid(e,t)}function n(t){return e(t)||Array.isArray(t)||"function"==typeof t}return we=function(o,i,s){if(e(s)||(s={default:s}),!n(o))return void 0!==s.default?s.default:o;"number"==typeof i&&(i=String(i));const a=Array.isArray(i),c="string"==typeof i,u=s.separator||".",l=s.joinChar||("string"==typeof u?u:".");if(!c&&!a)return o;if(c&&i in o)return r(i,o,s)?o[i]:s.default;let p=a?i:function(e,t,r){if("function"==typeof r.split)return r.split(e);return e.split(t)}(i,u,s),d=p.length,f=0;do{let e=p[f];for("number"==typeof e&&(e=String(e));e&&"\\"===e.slice(-1);)e=t([e.slice(0,-1),p[++f]||""],l,s);if(e in o){if(!r(e,o,s))return s.default;o=o[e]}else{let n=!1,i=f+1;for(;i!(e=>void 0===e)(e);function Ke(e,t,r,n=new Set){const o=r;return n.has(e)?(o[t]="[Circular Reference]",r):(n.add(e),Object(e)!==e?o[t]=e:Array.isArray(e)?(()=>{const r=e.length;for(let i=0;i{let r=!0;Object.keys(e).forEach((i=>{r=!1,Ke(e[i],t?`${t}.${i}`:i,o,n)})),r&&(o[t]={})})(),n.delete(e),o)}function Se(e,t,r,n){const o=[],s=t||{};return Array.isArray(r)?r.forEach((t=>{const r=Ae(e,t);r&&(Object.keys(r).forEach((e=>{n.includes(e)||o.push(e)})),o.forEach((e=>{void 0!==r[e]&&(s[e]=Ae(r,e))})))})):"root"===r?(Object.keys(e).forEach((e=>{n.includes(e)||o.push(e)})),o.forEach((t=>{void 0!==e[t]&&(s[t]=Ae(e,t))}))):i.debug("unable to parse keys"),s}const Fe=e=>je(e)&&(e=>null!==e)(e),De=({message:e,operationObject:t})=>{const{operation:r,args:n}=t,o=n.map((t=>{const{sourceKeys:r,defaultVal:n}=t,o=Ae(e,r);return o||!1===o||0===o?o:n}));if(!o.every((e=>Fe(e))))return null;let i=null;switch(r){case"multiplication":i=1;for(const e of o){if("number"!=typeof e)return null;i*=e}return i.toFixed(2);case"addition":i=0;for(const e of o){if("number"!=typeof e)return null;i+=e}return i.toFixed(2);default:return null}},ke=(e,t)=>{let r=e;const n={jsonStringify:()=>{r=JSON.stringify(e)},jsonStringifyOnObject:()=>{"string"!=typeof e&&(r=JSON.stringify(e))},toString:()=>{r=String(e)},toNumber:()=>{r=Number(e)},toFloat:()=>{r=parseFloat(e)},toInt:()=>{r=parseInt(e,10)},toLower:()=>{r=e.toString().toLowerCase()},trim:()=>{"string"==typeof e&&(r=e.trim())},IsBoolean:()=>{r=!0,"boolean"!=typeof e&&(i.debug("Boolean value missing, so dropping it"),r=!1)}};if(t in n){(0,n[t])()}return r},Re=(e,t)=>{const r={};return Array.isArray(t)&&t.length>0&&t.forEach((t=>{const{sourceKeys:n,destKey:o,metadata:i}=t,s=((e,t)=>{if(!t)return e;const{type:r,defaultValue:n}=t;if(!Fe(e))return n||e;let o=e;return r&&(Array.isArray(r)?r.forEach((e=>{o=ke(o,e)})):o=ke(o,r)),o})(((e,t)=>{if(Array.isArray(t)&&t.length>0){for(const r of t){let t;if(t="object"==typeof r?De({message:e,operationObject:r}):Ae(e,r),t||!1===t||0===t)return t}return null}return"object"==typeof t?De({message:e,operationObject:t}):Ae(e,t)})(e,n),i);(s||0===s||!1===s)&&o&&(r[o]=s)})),r};function xe(e,t=".",r="normal"){const n={};let o;return function e(i,s,a=new Set){let c;if(a.has(i))n[s]="[Circular Reference]";else{if(a.add(i),Object(i)!==i)n[s]=i;else if(Array.isArray(i)){for(c=0,o=i.length;c{r=!1,e(i[n],s?`${s}${t}${n}`:n,a)})),r&&s&&(n[s]={})}a.delete(i)}}(e,""),n}const Pe=new ye(f),Ue=e=>e.split(".").pop(),Ne=e=>{const t={};if("object"==typeof e&&!Array.isArray(e)){return Object.keys(e).forEach((r=>{const n=e[r];("items"===r||"object"!=typeof n&&!(e=>"string"==typeof e&&pe(e.trim()))(n))&&(t[r]=n)})),t}return e},Te=(e,t,r)=>{let n={};return n=Se(e,n,t,r),p(n)||(n=xe(n,"_","strict")),n},Le=e=>{const t=[],{properties:r}=e;let o=null==r?void 0:r.products,i=!1;return"object"!=typeof o||Array.isArray(o)||(i=!0,o=[o]),Array.isArray(o)&&o.forEach(((r,o)=>{let s=Re(r,ge);const a=Se(e,{},i?["properties.products"]:[`properties.products.${o}`],me);p(a)||(s=Ne(n(n({},s),xe(a,"_","strict")))),p(s)||t.push(s)})),t},$e=e=>{const{properties:t}=e,r=[];if(t&&Object.keys(t).length>0){const e=Re(t,ge);p(e)||r.push(e)}return r},qe=(e,t)=>{const{event:r,mapping:o}=t;let i=Re(e,o);if(Array.isArray(o)&&o.length>0){if(o.some((e=>{return t=i[e.destKey],!(je(t)&&(e=>null!=e)(t)||!e.required)&&(Pe.error(`Missing required value from ${JSON.stringify(e.sourceKeys)}`),!0);var t})))return null}const{items:s,mapRootLevelPropertiesToGA4ItemsArray:a}=((e,t)=>{const{itemList:r,item:n}=t;let o=[],i=!1;return r&&n?(o=Le(e),o&&o.length>0||(i=!0,o=$e(e))):n?(i=!0,o=$e(e)):r&&(o=Le(e)),{items:o,mapRootLevelPropertiesToGA4ItemsArray:i}})(e,t),c=((e,t,r)=>{let n=t.reduce(((e,t)=>{const r=t.sourceKeys;return"string"==typeof r?e.push(Ue(r)):Array.isArray(r)&&r.forEach((t=>{"string"==typeof t&&e.push(Ue(t))})),e}),[]);return n.push("products"),e&&_e.includes(r)&&(n=n.concat(me)),n})(a,o,r),u=Te(e,["properties"],c);return s.length>0&&(i.items=s),p(u)||(i=n(n({},i),u)),i},Me=(e,t)=>{const r=ve[`${t.toUpperCase()}`],n=r?qe(e,r):(e=>Te(e,["properties"],[]))(e);if(!n)return null;return{params:Ne(n),event:r?r.event:t}},Be=new ye(f);return e.GA4=class{constructor(e,t,r){var n;t.logLevel&&Be.setLogLevel(t.logLevel),this.name="GA4",this.clientId="",this.sessionId="",this.sessionNumber="",this.cookie=de,this.sendUserId=!0,this.analytics=t,this.measurementId=e.measurementId,this.debugView=e.debugView||!1,this.capturePageView=e.capturePageView||"rs",this.isHybridModeEnabled="hybrid"===e.connectionMode,this.piiPropertiesToIgnore=e.piiPropertiesToIgnore||[],this.extendPageViewParams=e.extendPageViewParams||!1,this.overrideClientAndSessionId=e.overrideClientAndSessionId||!1,this.sdkBaseUrl=(null!=(n=e.sdkBaseUrl)&&n.endsWith("/")?n.replace(/\/+$/,""):n)||"https://www.googletagmanager.com",this.serverContainerUrl=e.serverContainerUrl||null,this.isExtendedGa4_V2=e.isExtendedGa4_V2||!1,({shouldApplyDeviceModeTransformation:this.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:this.propagateEventsUntransformedOnError,destinationId:this.destinationId}=null!=r?r:{})}loadScript(e,t){window.dataLayer=window.dataLayer||[],window.gtag=window.gtag||function(){window.dataLayer.push(arguments)},window.gtag("js",new Date);const r={};var n,o,i;if(Fe(this.serverContainerUrl)&&(r.server_container_url=this.serverContainerUrl),"rs"===this.capturePageView&&(r.send_page_view=!1),this.sendUserId=(n=this.analytics.loadOnlyIntegrations,null===(o=null==n||null===(i=n.GA4)||void 0===i?void 0:i.sendUserId)||void 0===o||o),this.sendUserId&&this.analytics.getUserId()&&(r.user_id=this.analytics.getUserId()),this.isHybridModeEnabled&&this.overrideClientAndSessionId)r.cookie_prefix="rs",r.client_id=this.analytics.getAnonymousId(),r.session_id=this.analytics.getSessionId();else if(!this.isExtendedGa4_V2){const e=this.cookie.get("rs_ga"),t=this.cookie.get("_ga"),n=this.measurementId.split("-"),o=this.cookie.get(`rs_ga_${n[1]}`);if(!t&&e&&o){const t=e.split("."),n=t.length>3?`${t[2]}.${t[3]}`:t[2],i=o.split(".")[2];n&&(r.client_id=n),i&&(r.session_id=i)}this.cookie.remove("rs_ga"),this.cookie.remove(`rs_ga_${n[1]}`)}this.debugView&&(r.debug_mode=!0),0===Object.keys(r).length?window.gtag("config",e):window.gtag("config",e,r),window.gtag("get",this.measurementId,"session_id",(e=>{this.sessionId=e})),window.gtag("get",this.measurementId,"client_id",(e=>{this.clientId=e})),window.gtag("get",this.measurementId,"session_number",(e=>{this.sessionNumber=e})),((e,t,r={})=>{try{if(document.getElementById(e))return;const n=document.createElement("script");n.src=t,n.async=void 0===r.async||r.async,n.type="text/javascript",n.id=e,!0!==r.skipDatasetAttributes&&(n.setAttribute("data-loader",s),void 0!==r.isNonNativeSDK&&n.setAttribute("data-isNonNativeSDK",r.isNonNativeSDK));const o=document.getElementsByTagName("head");if(o.length>0)o[0].insertBefore(n,o[0].firstChild);else{const e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)}}catch(e){d(e)}})("google-analytics 4",`${t}/gtag/js?id=${e}`)}init(){this.loadScript(this.measurementId,this.sdkBaseUrl)}isLoaded(){return!(!this.sessionId||!this.clientId)}isReady(){return this.isLoaded()}identify(e){const{message:t}=e,{traits:r}=t.context,o=((e,t)=>{const r=[],o={},i=t,s={};return e.length>0&&e.forEach((e=>{"string"==typeof e.piiProperty&&""!==e.piiProperty.trim()&&r.push(e.piiProperty.trim())})),Object.keys(i).forEach((e=>{const t=i[e];r.includes(e)?o[e]=null:s[e]=t})),n(n({},o),s)})(this.piiPropertiesToIgnore,r);if(Object.keys(o).length>0&&window.gtag("set","user_properties",o),this.sendUserId&&t.userId){const{userId:e}=t;window.gtag("config",this.measurementId,{user_id:e})}}track(e){if(this.isHybridModeEnabled)return;const{message:t}=e,r=(e=>{if(!e||"string"!=typeof e)return Pe.error("Event name is required and should be a string"),null;const t=e.trim().replace(/\s+/g,"_");return["click","error","scroll","form_start","form_submit","first_open","first_visit","app_remove","video_start","session_start","view_complete","file_download","video_progress","user_engagement","in_app_purchase","app_store_refund","app_store_subscription_cancel","app_store_subscription_renew"].includes(t)?(Pe.error(`Reserved event name ${t} is not allowed`),null):t})(null==t?void 0:t.event);if(!r)return void Be.error("Event name is required");const n=Me(t,r);if(!n)return;const{params:o,event:i}=n,s=this.addSendToAndMeasurementIdToPayload(o,e);window.gtag("event",i,s)}page(e){if("rs"===this.capturePageView){const{message:t}=e,{properties:r}=t;let o=Re(t,ve.PAGE.mapping);o=this.addSendToAndMeasurementIdToPayload(o,e),this.extendPageViewParams?window.gtag("event","page_view",n(n({},function(e,t=""){return Ke(e,t,{})}(r)),o)):window.gtag("event","page_view",o)}}group(e){if(this.isHybridModeEnabled)return;const{groupId:t,traits:r}=e.message;let o=r;o=this.addSendToAndMeasurementIdToPayload(o,e);const i=n({group_id:t},o);window.gtag("event","join_group",i)}addSendToAndMeasurementIdToPayload(e,t){const{message:r}=t,{userId:n}=r,o=e;return o.send_to=this.measurementId,this.sendUserId&&n&&(o.user_id=n),o}getDataForIntegrationsObject(){return{[f]:{clientId:this.clientId,sessionId:this.sessionId,sessionNumber:this.sessionNumber}}}getClientDetails(){return{clientId:this.clientId,sessionId:this.sessionId,sessionNumber:this.sessionNumber}}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({}); //# sourceMappingURL=GA4.min.js.map